<?php

namespace app\admin\model;

use think\Model;

class WechatUser extends Model
{
    // 表名
    protected $name = 'wechat_user';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    
    // 追加属性
    protected $append = [
        'gender_text',
        'isleader_text',
        'enable_text'
    ];
    

    
    public function getGenderList()
    {
        return ['1' => __('Gender 1'),'2' => __('Gender 2')];
    }     

    public function getIsleaderList()
    {
        return ['1' => __('Isleader 1'),'0' => __('Isleader 0')];
    }     

    public function getEnableList()
    {
        return ['1' => __('Enable 1'),'0' => __('Enable 0')];
    }     


    public function getGenderTextAttr($value, $data)
    {        
        $value = $value ? $value : $data['gender'];
        $list = $this->getGenderList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsleaderTextAttr($value, $data)
    {        
        $value = $value ? $value : $data['isleader'];
        $list = $this->getIsleaderList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getEnableTextAttr($value, $data)
    {        
        $value = $value ? $value : $data['enable'];
        $list = $this->getEnableList();
        return isset($list[$value]) ? $list[$value] : '';
    }




}
